import React, { Component } from 'react'
import 'antd/dist/antd.css';
import { Button, Space , Table } from 'antd';
import TWiceModal from './ModalForm';



export default class TwiceCheck extends Component {
    constructor(props) {
        super(props);
        this.state = {
          flag: false  // 初始为false
        }
      }
      // 点击后改为true 渲染D组件
      fun = () => {
        this.setState({
          flag: true
        }, () => {
          console.log('APP state flag ', this.state.flag)
        }) // 回调函数
      }
      
      AA = () =>{
        alert("确定要修改吗？")
      }

      setParentState =()=>{
        debugger;
        this.setState={
          visible:false
        }
      }


      render() {
        const dataSource = [
          {
            key: '1',
            name: '胡彦斌',
            age: 32,
            address: '西湖区湖底公园1号',
          },
          {
            key: '2',
            name: '胡彦祖',
            age: 42,
            address: '西湖区湖底公园1号',
          },
        ];
        
        const columns = [
          {
            title: '姓名',
            dataIndex: 'name',
            key: 'name',
          },
          {
            title: '年龄',
            dataIndex: 'age',
            key: 'age',
          },
          {
            title: 'Action',
            key: 'action',
            render: (text, record) => (
              <Space size="middle">
                <Button onClick={this.fun} >修改</Button>
                <Button onClick={this.fun} >修改</Button>
              </Space>
            ),
          },
        ];
        return (
          <div className='App'>
            <h2>机构复检报告单</h2>
            <Table dataSource={dataSource} columns={columns} />
            {
              this.state.flag && <TWiceModal setParentState={this.setParentState} visible={true} AA={this.AA} data={'name'}  />
            }
          </div>
        )
}
}